package com.admin.controller;

import com.common.domain.dto.DoctorDto;
import com.common.domain.entity.Leave;
import com.common.domain.entity.ResponseResult;
import com.common.domain.vo.DoctorInfoVo;
import com.common.service.DoctorService;
import com.common.service.LeaveService;
import com.common.service.VisitRecordService;
import com.common.util.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("system/leave")
public class LeaveController {
    @Autowired
    private LeaveService leaveService;
    @Autowired
    private DoctorService doctorService;

    @GetMapping("/list")
    public ResponseResult allLeaveList(Integer pageNum, Integer pageSize, Long userId, String startTime,String endTime, String status){
        return leaveService.allLeaveList(pageNum,pageSize,userId,startTime,endTime,status);
    }

    @GetMapping("/updateLeaveStatus")
    public ResponseResult updateLeaveStatus(Long id, String reason, String type){
        return leaveService.updateLeaveStatus(id,reason,type);
    }

    @GetMapping("/getDoctorLeaveInfo")
    public ResponseResult getDoctorLeaveInfo(){
        DoctorInfoVo info = doctorService.getInfo();
        return ResponseResult.okResult( doctorService.getDoctorLeaveInfo(info.getDocId(), "2"));
    }


    @GetMapping("/getLeaveInfoList")
    public ResponseResult getLeaveInfoList(Integer pageNum, Integer pageSize,String status){
        return leaveService.getLeaveInfoList(pageNum, pageSize, status);
    }

    @PostMapping("/addLeaveInfo")
    public ResponseResult addLeaveInfo(@RequestBody Leave leave){
        return doctorService.addLeaveInfo(leave);
    }

    @PutMapping("/updateLeaveInfo")
    public ResponseResult updateLeaveInfo(@RequestBody Leave leave){
        return doctorService.updateLeaveInfo(leave);
    }
}
